// --------------------------------------------------------------------------------------------------------------------
// <copyright file="MainViewModel.cs" company="XamlmNinja">
//   2010
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace ResumableDownload.ViewModel
{
    using System;
    using GalaSoft.MvvmLight.Messaging;
    using Messages;
    using WP7Contrib.Logging;
    using WP7Contrib.Services.Navigation;

    public class Mp3ViewModel : ViewModelBaseWp7
    {
        private string source;

        public Mp3ViewModel(INavigationService navigationService, IMessenger messenger, ILog log)
            : base(navigationService, messenger, log)
        {
            this.MessengerInstance.Register<SelectedMp3Message>(this, this.HandleSelectedMp3Message);
        }

        public string Source
        {
            get { return this.source; }
            set
            {
                this.SetPropertyAndNotify(ref this.source, value, "Source");
            }
        }

        public override void Cleanup()
        {
            base.Cleanup();
        }

        private void HandleSelectedMp3Message(SelectedMp3Message message)
        {
            if (string.IsNullOrEmpty(message.FilePath))
                return;

            this.Source = message.FilePath;
        }
    }
}